package com.yzt.message.custom;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.yzt.message.R;

import java.util.List;

import io.rong.imkit.conversation.messgelist.provider.BaseMessageItemProvider;
import io.rong.imkit.model.UiMessage;
import io.rong.imkit.widget.adapter.IViewProviderListener;
import io.rong.imkit.widget.adapter.ViewHolder;
import io.rong.imlib.model.MessageContent;


public abstract class CustomBaseMessageItemProvider<T extends MessageContent> extends BaseMessageItemProvider<T> {

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View rootView = LayoutInflater.from(parent.getContext()).inflate(R.layout.nomi_rc_message_item, parent, false);
        FrameLayout contentView = rootView.findViewById(R.id.rc_content);
        ViewHolder contentViewHolder = this.onCreateMessageContentViewHolder(contentView, viewType);
        if (contentViewHolder != null && contentView.getChildCount() == 0) {
            contentView.addView(contentViewHolder.itemView);
        }
        return new BaseMessageItemProvider.MessageViewHolder(rootView.getContext(), rootView, contentViewHolder);
    }

    @Override
    public void bindViewHolder(ViewHolder holder, UiMessage uiMessage, int position, List<UiMessage> list, IViewProviderListener<UiMessage> listener) {
        super.bindViewHolder(holder, uiMessage, position, list, listener);
    }
}
